package com.xczl.book.action.admin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.shishuo.cms.entity.vo.PageVo;
import com.xczl.book.entity.User;
import com.xczl.book.service.UserService;

@Controller("bookAdminUserAction")
@RequestMapping("book/admin/user")
public class UserAction {

	@Autowired
	private UserService userService;

	@RequestMapping("index.htm")
	public String index(User searchVo,
			@RequestParam(value = "p", defaultValue = "1") int pageNum,
			ModelMap model) {
		PageVo<User> pageVo = userService.findPageVo(pageNum, searchVo);
		model.addAttribute("pageVo", pageVo);
		model.addAttribute("searchVo", searchVo);
		return "book/admin/user/index";
	}

	@RequestMapping("userBorrow.htm")
	public String userBorrow(int id, ModelMap model) {
		User user = userService.findById(id);
		model.addAttribute("user", user);
		return "book/admin/user/userBorrow";
	}
}
